package com.sweetpotato.fanshu;

import java.util.Scanner;

public class jiandaoshitoubu {
    public static void main(String[] args) {
        System.out.println("开始石头剪刀布游戏");
        Scanner John = new Scanner(System.in);
        System.out.println("请输入挑战者的名字：");
        String myName = John.next();
        System.out.println(myName + "，准备好了吗？(y/n)");
        String yRoN = John.next();
        int myWin = 0, enemyWin = 0;
        if (yRoN.equalsIgnoreCase("y")) {
            for (int i = 1; i <= 5; i++) {
                System.out.println("第" + i + "局开始");
                System.out.println(myName + ",请你出拳：1:石头 2:剪刀 3:布");
                int choice = John.nextInt();
                int enemychoice = (int) (Math.random() * 3) + 1;
                System.out.println(myName + "的出拳结果是" + (choice) + "敌人的出拳是" + (enemychoice));
                if ((choice == 1 && enemychoice == 2) || (choice == 2 && enemychoice == 3) || (choice == 3 && enemychoice == 1)) {//我赢了
                    System.out.println("第" + i + "局，你赢了");
                    myWin++;
                } else if (choice == enemychoice) {//平局了
                    System.out.println("第" + i + "局，平局");
                } else {//他赢了
                    System.out.println("第" + i + "局，你输了");
                    enemyWin++;
                }
            }
        }
    }
}
